package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/adChannel")
public class AdChAnnelController implements AdChannelControllerApi {
    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/findPage")
    @Override
    public PageResponseResult findBySearch(ChannelDto channelDto) {
        return adChannelService.findPage(channelDto);
    }

    @PostMapping("/save")
    @Override
    public ResponseResult save(AdChannel adChannel) {
        return adChannelService.save(adChannel);
    }

    @PostMapping("/{id}")
    @Override
    public ResponseResult findById(@PathVariable("id") Integer id) {
        return adChannelService.findById(id);
    }

    @PostMapping("/edit/{id}")
    @Override
    public ResponseResult edit(@PathVariable("id") Integer id, AdChannel adChannel) {
        return adChannelService.edit(id,adChannel);
    }

}
